﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPI.OrganizationDomain.Model.Entity;
using KPI.OrganizationDomain.Model.ValueObject;

namespace KPI.OrganizationDomain.Service
{
    public struct ValidationResult
    {
        public bool IsCorrect { get; set; }

        public string Message { get; set; }
    }

    /// <summary>
    /// This Validation class is used to check if input or output objects conform to business rules.
    /// </summary>
    public class Validation
    {
        /// <summary>
        /// Checks the department.
        /// </summary>
        /// <param name="department">The department.</param>
        /// <returns></returns>
        public static ValidationResult CheckDepartment(Department department)
        {
            ValidationResult result = new ValidationResult();
            result.IsCorrect = false;

            if (department.Name.Equals(string.Empty))
            {
                result.Message = MessageString.EmptyDepartmentName;
            }
            else if (department.Description.Equals(string.Empty))
            {
                result.Message = MessageString.EmptyDepartmentDescription;
            }
            else
                result.IsCorrect = true;

            return result;
        }

        public static ValidationResult CheckEmployee(Employee employeeDto)
        {
            ValidationResult result = new ValidationResult();
            result.IsCorrect = false;

            if (employeeDto.FirstName.Equals(string.Empty))
            {
                result.Message = MessageString.EmptyEmployeeName;
            }

            if (employeeDto.LastName.Equals(string.Empty))
            {
                result.Message = MessageString.EmptyEmployeeName;
            }
              if (employeeDto.LoginName.Equals(string.Empty))
            {
                result.Message = MessageString.EmptyEmployeeName;
            }
         
               else
                result.IsCorrect = true;

            return result;
        }
    }
}
